package com.topscomm.main;

import javax.annotation.Resource;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.TransactionManagementConfigurer;

import com.topscomm.pub.util.SpringUtil;
import org.springframework.util.FileSystemUtils;

import java.io.File;

@SpringBootApplication
@EnableTransactionManagement
@ComponentScan(basePackages = { "com.topscomm" })
public class MeetApp implements TransactionManagementConfigurer {
	@Resource(name = "transactionManager")
	private PlatformTransactionManager defaultTxManager;

	public static void main(String[] args) {
		SpringApplicationBuilder app = new SpringApplicationBuilder(MeetApp.class).web(WebApplicationType.SERVLET);
		app.build().addListeners(new ApplicationPidFileWriter());
		ApplicationContext ctx = app.run(args);
		SpringUtil springUtil = (SpringUtil) SpringUtil.getBean("springUtil");
		springUtil.setApplicationContext(ctx);
	}

	@Override
	public PlatformTransactionManager annotationDrivenTransactionManager() {
		return defaultTxManager;
	}
}
